import React from 'react';
import { useLocation } from 'react-router-dom';

const withRefreshOnListRoute = (WrappedComponent) => {
  return function WithRefreshOnListRoute(props) {
    const location = useLocation();
    React.useEffect(() => {
      if (location.pathname.includes('/chatlist')) {
        const Elements = document.getElementById('sheld')
        if (Elements) {
          Elements.style.display = 'none';
        } 
      }
    }, [location]);

    return React.createElement(WrappedComponent, props);
  }
}

export default withRefreshOnListRoute;
